function staffTypeFormatter(value, row){
	return getTableColumnValueByDict($("#roleNameList").val(), value);
}

function buttonFormatter(value, row,index) {
  	var d = "<button id='btn_edit' type='button' onclick='_update("+row.rowId+");'  class='btn btn-default btn-sm'><span class='glyphicon glyphicon-pencil'></span>修 改</button>";
  	return d; 
}
   
function useFlagFormatter(value, row) {
	if (row.verState == 1) {
    	return ' <span class="text-success">是 </span>';
	} else if (row.verState == 0) {
    	return ' <span class="text-warning">否 </span>';
	} 
}

// 弹出添加的窗口
function add(){
	layer.open({
	  	type: 2,
	  	title: "新增版本配置",
	  	closeBtn: 1,
	  	shadeClose: true,
	  	area: ['570px', '500px'],
	  	content: JSSYSMANAGERV1 + '/sysAppVersion/toAddAppVersion',
		btn: ["确 认","关 闭"], 
	  	yes: function(index, layero){
	    	var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
	        iframeWin.add();
	  	}
	});
}
// 弹出添加的窗口      修改功能
function _update(uid){
	layer.open({
	  	type: 2,
	  	title: "版本维护",
	  	closeBtn: 1,
	  	shadeClose: true,
	  	area: ['560px', '490px'],
	  	content: JSSYSMANAGERV1 + '/sysAppVersion/editor?uid='+uid,
	  	btn: ["确 认","关 闭"], 
	  	yes: function(index, layero){
		    var iframeWin = window[layero.find('iframe')[0]['name']]; //得到iframe页的窗口对象，执行iframe页的方法：
		    iframeWin.add();
	  	}
	});
}
//  启用/停用
function _stop(rowId, flag, staffName){
	var descStr = "【停用员工】<a style='color:red'>"+'"'+staffName+'"'+"</a>";
	if (flag == 0) {
		descStr = "【启用员工】<a style='color:red'>"+'"'+staffName+'"'+"</a>";
	}
	layer.confirm('您确认'+descStr+'吗？', {
  	btn: ['确认', '取消']  
	}, 
	function(){
		if (rowId == null || rowId == '') {
			layer.msg("id不能为空!");
			return;
		}
		$.post(JSSYSMANAGERV1 + "/staff/stop?id="+rowId,null,function(json){
			if (json == 1) { 
	    		layer.alert("操作成功", {icon: 1});
				findData();
			} else {
	    		layer.alert("操作失败", {icon: 5});
			}
 	 	});
	}, 
	function(){
	   return;
	});
}

//删除
function _delete(rowId, staffName){
 	layer.confirm('确认删除员工<a style="color:red">'+'"'+staffName+'"'+'</a>吗？', {
  	btn: ['确认', '取消']  
	}, 
	function(){
		if (rowId == null || rowId == '') {
			layer.msg("id不能为空!");
			return;
		}
		$.post(JSSYSMANAGERV1 + "/staff/deleteStaff?id="+rowId,null,function(json){
			if (json == 1) { 
		    	layer.alert("删除员工操作成功", {icon: 1});
				findData();
			} else if (json == 2) {
			    layer.alert("该员工没有停用，不能删除", {icon: 5});
				return;
			} else {
 				layer.alert("删除员工操作失败", {icon: 1});
  			}
 	 	});
	},
	function(){
	   return;
	}); 
}
//重置密码
function _reset(rowId){
	var descStr = "【重置密码】";
	layer.confirm('您确认'+descStr+'?', {
  	btn: ['确认', '取消']  
	}, 
	function(){
		var url = JSSYSMANAGERV1 + "/staff/resetPwd?id="+rowId;
		$.post(url,null,function(data){
  		    if (data == 1) { 
  		        layer.alert(descStr+"操作成功", {icon: 1});
			} else {
    			layer.alert(descStr+"操作失败", {icon: 5});
  			}
		});
	}, 
	function(){ 
	   	return;
	});
}
// 加载table 数据
$(function(){
	$("#dataTable").bootstrapTable({ 
		url: JSSYSMANAGERV1 + "/sysAppVersion/appVersion.json",
		method:"get", 
		pagination:true,
		sidePagination:"server",
		queryParams: function(params) {
	    	return $.extend({}, params, parseJson(decodeURIComponent($("#dataForm").serialize())));     
        }
   }); 
})
function findData(){
	$("#dataTable").bootstrapTable("refresh",{} ); 
}

/*bootstrap table点击行事件*/
$(function(){
	 $("body").on("click","table>tbody>tr",function(){
      $(this).css("background","#e1ecf1").siblings().css("background","");
   });
})